<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {

            position: relative;
            width: 160px;
            height: 181px;
            margin: 200px auto;
            border: 1px solid #ccc;

        }

        .box i {
            position: absolute;
            display: block;
            width: 20px;
            height: 20px;
            top: 0;
            left: -22px;
            border: 1px solid #ccc;
            text-align: center;
            line-height: 20px;
            cursor: pointer;
            font-family: Verdana, Geneva, Tahoma, sans-serif
        }
    </style>
</head>

<body>
    <div class="box">
        淘宝二维码
        <img src="images/tao.png" alt="">
        <i class="close-btn">x</i>
    </div>
    <script>
        var btn = document.getElementsByClassName('close-btn');
        var box = document.getElementsByClassName('box');
        // console.dir();
        btn[0].onclick = function () {
            console.log('1');
            box[0].style.display = 'none';
        }
    </script>
</body>

</html>